package study.ssm.service.impl;

import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import study.ssm.entity.Product;
import study.ssm.mapper.ProductMapper;
import study.ssm.service.ProductService;

import java.util.List;

@Service
@RequiredArgsConstructor
@Transactional
public class ProductServiceImpl implements ProductService {

    private final ProductMapper productMapper;


    @Override
    public Integer create(Product product) {
        return productMapper.insert(product);
    }

    @Override
    public Integer removeById(Integer id) {
        return productMapper.deleteById(id);
    }

    @Override
    public Integer update(Product product) {
        return productMapper.updateById(product);
    }

    @Override
    public List<Product> list(Product product) {
        return productMapper.selectList(product);
    }

    @Override
    public Product getById(Integer id) {
        return productMapper.selectById(id);
    }
}
